
let postUrl = 'http://121.43.153.61:9090';
let token = 'Bearer ' + window.GlobalToken

function getUrlParams(name) {
  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  var r = window.location.search.substr(1).match(reg);
  if (r != null)
    return unescape(r[2]);
  return null;
}
// 开始游戏
function playGame(){
  let game_id = getUrlParams('game_id')
  console.log(game_id,'last')
  window.ndkLaunchGame(game_id);
}
function getDetail() {
  // ${game_id}
  $.ajax({
    url: postUrl + `/api/v1/game/detail/${getUrlParams('game_id')}`,
    // url: postUrl + `/api/v1/game/detail/89071613`,
    method: 'get',
    // 通过headers对象设置请求头
    headers: { 'Content-Type': 'application/json', 'Authorization': token },
    data: {},
    dataType: 'json',
    //async: true,
    success: function (res) {
      if (res.code === 200) {
        let result = res.data
        let name = document.querySelector('.name')
        let type = document.querySelector('.type')
        let text = document.querySelector('.text')
        let detail = document.querySelector('#detail')
        let video_list = document.querySelector('.video_list')
        let top_l = document.querySelector('.top_l')
        let topImg = `
         <div class="top_l">
        <img src="${result.cover}" alt="" class="top_img" />
      </div>
        `
        top_l.innerHTML = topImg
        name.innerHTML = result.gameName
        type.innerHTML = result.type
        text.innerHTML = result.introduction
        let img = result.pic.split(',')
        let video = result.video.split(',')
        console.log(img, 'imgs')
        console.log(video, 'videos')
        let listStr = ''
        img.forEach((item, index) => {
          listStr += `
          <div class="detail" >
        <img src="${item}" alt="" class="detail_img" />
      </div>
          `
        })
        detail.innerHTML = listStr

        let listStrs = ''
        video.forEach((item, index) => {
          listStrs += `
       <div class="list_item">
        <video src="${item}" class="video" autoplay  enable-danmu danmu-btn controls></video>
      </div>
        `
        })
        video_list.innerHTML = listStrs
      }
    },
    error: function (e) {
    }
  })
}

getDetail()